Traditional destination-based routing mechanism employs a routing table to forward packets, according to destination address. However, in this approach, a router can merely provide a single routing mode for users based on destination address of packets and solve the problem about forwarding network data, but cannot provide services for users to control the forwarding of packets.
In order to enable the routing function to have more powerful controlling capability and to be utilized more flexibly, a policy routing method has been adopted currently. The policy routing is defined as a kind of a routing mechanism, which forwards a data packet based on the user-defined policies. The user may select a forward path, according to a packet source address, a packet length and other criteria, besides a destination address. Implementing of policy routing may be defined according to actual application requirements, such as controlling a load balance among a plurality of routers, satisfying the quality of service (QoS) of packet forwarding in a single link, and the like. The policy routing includes interface policy routing and local policy routing. The interface policy routing is configured to forward packets reaching the interface, and the local policy routing is configured to perform policy routing on packets generated locally.
However, the policy routing method may influence the router in terms of transmitting local packets and forwarding packets from the interface. That is to say, when a user employs the method for policy routing to transmit or forward packets, the user needs to firstly search for a nodes of policy to determine whether there is a policy node matching the packet or not. If a policy node matched the packet is obtained, the packet is transmitted according to forwarding information described in the node of policy; and if no matched node of policy is obtained, the packet is transmitted or forwarded according to a conventional routing approach. When the matched policy node is obtained, the method can enhance the transmitting and forwarding efficiencies; and when no matched node of policy is obtained, the method may reduce the transmitting and forwarding efficiencies. That is because certain comparison time is required for traversing and matching the nodes of policy, and the efficiency reduction extent is in a linear relation with the policy routing scale configured by the user, i.e. the number of nodes of policy. Under general conditions, the policy routing scale configured by the user is very small, and the number of policy nodes is no more than 200, and thus the packet transmitting and forwarding efficiencies are influenced in a rather small extent.
At present, the conventional policy routing approach includes a policy routing to an outgoing interface and a policy routing to a next-hop, in which a command line interface is provided, so that the user is enabled to manually intervene the forwarding of some packets. For example, according to a packet type, a source address or destination address, a packet size, and other information, the outgoing interface or the next-hop may be selected flexibly to instruct the motion of forwarding a packet. The policy routing configuration includes defining conditions for a packet requiring the policy routing and designating an outgoing interface and next-hop for a packet satisfying the conditions. To forward a packet, the router firstly searches for a matched node of policy, and if no matched node of policy is obtained, the router searches for the routing according to a destination address based on the conventional routing approach; and if a matched node of policy is obtained, the router firstly sets a priority level for the packet according to the priority level set by the user, and then determines whether the user has set a transmission interface of the policy routing or not. If the user has set the transmission interface, the packet is transmitted via the interface set by the user; and if the user does not set the transmission interface, it is further determined whether the user has set a next-hop of the policy routing or not. If the user has set the next-hop of the policy routing, the packet is transmitted to the next-hop; otherwise, a routing is searched for according to a destination address of the packet based on the conventional routing approach. If no node of policy matching the routing is obtained, the packet is transmitted to a default transmission interface set by the user; if the user does not set the default transmission interface, the packet is transmitted to a default next-hop; and if the user does not set the default next-hop of the policy routing, the packet is dropped.
According to the study on the aforementioned technologies, the inventor finds out the following technical problems: the method of policy routing to an outgoing interface or policy routing to a next-hop is merely applicable to policy routing of internet protocol (IP) packets, but cannot well support policy routing of other kinds of packets, for example, policy routing of multi-protocol label switching (MPLS) packets. In addition, the method of policy routing to an outgoing interface cannot be applicable to an Ethernet interface, because the Ethernet interface is a broadcast-type interface, and a designated outgoing interface cannot obtain a hardware address of an opposite terminal. What's more, since an IP packet is forwarded hop by hop, the method of policy routing to an outgoing interface and policy routing to a next-hop can merely be configured to forward a packet by one hop. That is to say, after a packet is transmitted from a certain interface of the router, the subsequent forwarding motions of the packet cannot be planned any more, i.e. the subsequent forward paths of the packet cannot be predicted.